// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { TableViewCell } from "../../../../quick/core/ui/TableViewCell";
import { inject } from "../../../../quick/defines/Decorators";


const {ccclass, property} = cc._decorator;

export interface CellData{
    content : string,
    type : number,
}

@ccclass
export default class TestTableViewCell extends TableViewCell {

    @inject("label",cc.Label)
    private _label : cc.Label = null;
    @inject("button",cc.Button)
    private _button : cc.Button = null;

    onLoad(){
        super.onLoad && super.onLoad();
        this.onN(this._button.node,cc.Node.EventType.TOUCH_END,this.onClick);
    }

    init(){
        // this._label = cc.find("label",this.node).getComponent(cc.Label);
        // this._button = cc.find("button",this.node).getComponent(cc.Button);
    }

    willRecycle(): void {
        // this._button.node.off(cc.Node.EventType.TOUCH_END);
    }

    updateData(v : CellData){
        this._label.string = v.content;
        // this._button.node.on(cc.Node.EventType.TOUCH_END,this.onClick,this);
    }

    get string(){
        return this._label.string;
    }

    private onClick(){
        Log.d("当前点击:",this.string);
    }
}
